//Edit by AiYan, 11839387

package user.ucm;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import user.model.UserModel;

public class UCRegistering {
    private UserModel um;

    public UCRegistering(UserModel um){
        this.um = um;
    }

    public int run() {
        try {
            Class.forName("com.mysql.jdbc.Driver");

            Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/cp3120?user=root&password=root");
            con.setCatalog("cp3120");

            Statement statement = con.createStatement();
            String sql = "INSERT INTO userinfo VALUES(" +
                    "'"+um.getName()+"','"+um.getPsw()+"',"+um.getAge()+",'"+um.getActure_name()+"',0,0)";
            System.out.println(sql);
            statement.execute(sql);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }
}
